Board = cc.Node.extend({
	ctor:function(p){
		this._super();
		p.addChild(this, 10, TAG_BOARD);
		this.init();
	},
	init : function(){
		this.setCascadeOpacityEnabled(true);

		var board = new Button(this, 10, TAG_BOARD1, "#yiqi/board.png",this.callback);
		board.setPosition(1100,350);
		board.setVisible(false);
		var board_left = new Button(this, 10, TAG_BOARD2, "#yiqi/half_board.png",this.callback);
		board_left.setPosition(575.5,416.5);
		board_left.setVisible(false);
		var board_right = new Button(this, 10, TAG_BOARD3, "#yiqi/half_board.png",this.callback);
		board_right.setAnchorPoint(0,0.5);
		board_right.setPosition(637.5,416.5);
		board_right.setVisible(false);
		var board_scale = new Button(this, 10, TAG_BOARD4, "#yiqi/scale_board1.png",this.callback);
		board_scale.setPosition(634,442.5);
		board_scale.setVisible(false);
	},
	
	callback:function(p){
		var action = gg.flow.flow.action;
		var func=cc.callFunc(function() {
			gg.flow.next();
		},this);
		switch(p.getTag()){	
		case TAG_BOARD1:
			if(action==ACTION_DO1){
				var ber = cc.bezierTo(2, [cc.p(900,500),cc.p(700,500),cc.p(638,416.5)]);
				var seq = cc.sequence(ber,cc.callFunc(function(){
					this.getChildByTag(TAG_BOARD1).setVisible(false);
					this.getChildByTag(TAG_BOARD2).setVisible(true);
					this.getChildByTag(TAG_BOARD3).setVisible(true);
				},this),func);
			}
			else if(action==ACTION_DO2)
			{
				
				var seq = cc.sequence(cc.callFunc(function(){				
					this.getChildByTag(TAG_BOARD1).setVisible(false);
					this.getChildByTag(TAG_BOARD4).setVisible(true);
					var arrow1 = ll.run.getChildByTag(TAG_SOURCE).getChildByTag(TAG_SOURCE1).getChildByTag(TAG_ARROW1);
					var arrow2 = ll.run.getChildByTag(TAG_SOURCE).getChildByTag(TAG_SOURCE1).getChildByTag(TAG_ARROW2);
					arrow1.setVisible(true);
					arrow2.setVisible(true);
					var source = ll.run.getChildByTag(TAG_SOURCE).getChildByTag(TAG_SOURCE1);
					ll.run.source.addListener(source);
			},this),func);
			}
			p.runAction(seq);
			break;	
		case TAG_BOARD3:
			var board_right = this.getChildByTag(TAG_BOARD3);			
			var rotate = cc.rotateBy(2, 0, 25);
			var seq = cc.sequence(cc.spawn(rotate,cc.callFunc(function(){
				ll.run.getChildByTag(TAG_SOURCE).getChildByTag(TAG_LINE1).setVisible(false);
			},this)),cc.delayTime(1),rotate.reverse(),cc.callFunc(function(){
				ll.run.getChildByTag(TAG_SOURCE).getChildByTag(TAG_LINE1).setVisible(true);
				this.getChildByTag(TAG_BOARD1).setVisible(true);
				this.getChildByTag(TAG_BOARD2).setVisible(false);
				this.getChildByTag(TAG_BOARD3).setVisible(false);
				
			},this),func);
			p.runAction(seq);		
		break;			
		}
		
	},
});